package response

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

type BaseResponse struct {
	Data    interface{} `json:"data,omitempty"`
	Success bool        `json:"success"`
	Code    int         `json:"code"`
	Msg     string      `json:"msg,omitempty"`
}

func Suc(c *gin.Context, data interface{}) {
	c.JSON(http.StatusOK, BaseResponse{
		Data:    data,
		Success: true,
		Code:    200,
		Msg:     "",
	})
}

func Fail(c *gin.Context, httpCode int, err error) {
	c.JSON(httpCode, BaseResponse{
		Success: false,
		Code:    httpCode,
		Msg:     err.Error(),
	})
}
